home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / guis / iedit / developer / expanders / backfill / funcs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-23  |  8.2 KB  |  340 lines

  1. /// Includes
  2. #define INTUI_V36_NAMES_ONLY
  3.  
  4. #include <exec/nodes.h>                 // exec
  5. #include <exec/lists.h>
  6. #include <exec/memory.h>
  7. #include <exec/types.h>
  8. #include <dos/dos.h>                    // dos
  9. #include <intuition/intuition.h>        // intuition
  10. #include <intuition/gadgetclass.h>
  11. #include <graphics/text.h>              // graphics
  12. #include <graphics/gfxmacros.h>
  13. #include <libraries/gadtools.h>         // libraries
  14. #include <clib/exec_protos.h>           // protos
  15. #include <clib/dos_protos.h>
  16. #include <clib/intuition_protos.h>
  17. #include <clib/graphics_protos.h>
  18. #include <pragmas/exec_pragmas.h>       // pragmas
  19. #include <pragmas/dos_pragmas.h>
  20. #include <pragmas/intuition_pragmas.h>
  21. #include <pragmas/graphics_pragmas.h>
  22.  
  23.  
  24. #include <stdarg.h>
  25. #include <string.h>
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <ctype.h>
  29.  
  30. #include "DEV_IE:Expanders/defs.h"
  31. ///
  32. /// Prototypes
  33. /* we use the minimal version of the ObjectInfo */
  34. struct BFInfo {
  35.     struct Node Node;
  36.     UWORD       Kind;
  37.     UBYTE       Flags;
  38. };
  39. ///
  40.  
  41.  
  42.  
  43. /*  Starting function           */
  44. /// IEX_Mount
  45. __geta4 ULONG IEX_Mount( __A0 struct IE_Data *IE )
  46. {
  47.     BPTR                    DescFile;
  48.     struct FileInfoBlock   *fib;
  49.     ULONG                   ret = IEX_ERROR_NO_DESC_FILE;
  50.     static UBYTE            FileName[] = "PROGDIR:Expanders/BackFill.desc";
  51.  
  52.     Forbid();   /* we're going to write to a GLOBAL variable */
  53.  
  54.     if( Desc ) {            /* already mounted? */
  55.     Permit();
  56.     return( IEX_OK );
  57.     }
  58.  
  59.     LibBase->Kind      = IEX_OBJECT_KIND;
  60.  
  61.     LibBase->Resizable = FALSE;
  62.     LibBase->Movable   = FALSE;
  63.     LibBase->HasItems  = FALSE;
  64.     LibBase->UseFonts  = FALSE;
  65.  
  66.     LibBase->Node.ln_Name = "BACK FILL";
  67.  
  68.     if( fib = AllocDosObject( DOS_FIB, NULL )) {
  69.     if( DescFile = Lock( FileName, ACCESS_READ )) {
  70.  
  71.         Examine( DescFile, fib );
  72.         UnLock( DescFile );
  73.  
  74.         if( Desc = AllocVec( fib->fib_Size, 0L )) {
  75.         if( DescFile = Open( FileName, MODE_OLDFILE )) {
  76.  
  77.             Read( DescFile, Desc, fib->fib_Size );
  78.             Close( DescFile );
  79.  
  80.             ( *IE->IEXFun->SplitLines )( Desc ); // VERY important!
  81.  
  82.             STRPTR pri;
  83.  
  84.             pri = ( *IE->IEXFun->GetFirstLine )( Desc, "RENDPRI" );
  85.  
  86.             if( pri )
  87.             LibBase->Node.ln_Pri = atoi( pri );
  88.             else
  89.             LibBase->Node.ln_Pri = 0;
  90.  
  91.             ret = IEX_OK;
  92.  
  93.         } else {
  94.             FreeVec( Desc );
  95.             Desc = NULL;
  96.         }
  97.         }
  98.  
  99.     }
  100.  
  101.     FreeDosObject( DOS_FIB, fib );
  102.     }
  103.  
  104.     Permit();
  105.  
  106.     return( ret );
  107. }
  108. ///
  109.  
  110.  
  111. /*  Edit functions              */
  112. /// IEX_Add
  113. __geta4 BOOL IEX_Add( __D0 UWORD ID, __A0 struct IE_Data *IE, __D1 WORD x, __D2 WORD y, __D3 UWORD width, __D4 UWORD height )
  114. {
  115.     struct BFInfo  *bf;
  116.     BOOL            ret = FALSE;
  117.  
  118.     /* we're a /toggle/ object ;-) */
  119.     bf = IE->win_info->wi_Gadgets.mlh_Head;
  120.     while(( bf->Node.ln_Succ ) && ( bf->Kind != ID ))
  121.     bf = bf->Node.ln_Succ;
  122.  
  123.     if( bf->Node.ln_Succ ) {
  124.     IE->win_info->wi_NumObjects -= 1;
  125.  
  126.     Remove(( struct Node * )bf );
  127.     FreeMem( bf, sizeof( struct BFInfo ));
  128.  
  129.     return( TRUE );
  130.     }
  131.  
  132.     if( bf = AllocMem( sizeof( struct BFInfo ), MEMF_CLEAR )) {
  133.  
  134.     bf->Kind   = ID;       /* DON'T FORGET!!! */
  135.  
  136.     /* add our object to the list */
  137.     AddTail((struct List *)&IE->win_info->wi_Gadgets, (struct Node *)bf );
  138.  
  139.     IE->win_info->wi_NumObjects += 1;
  140.  
  141.     ret = TRUE;
  142.     }
  143.  
  144.     return( ret );
  145. }
  146. ///
  147. /// IEX_Remove
  148. __geta4 void IEX_Remove( __D0 UWORD ID, __A0 struct IE_Data *IE )
  149. {
  150.     struct BFInfo  *bf;
  151.  
  152.     for( bf = IE->win_info->wi_Gadgets.mlh_Head; bf->Node.ln_Succ; bf = bf->Node.ln_Succ )
  153.     if(( bf->Kind == ID ) && ( bf->Flags & G_ATTIVO )) {
  154.         struct BFInfo *bf2 = bf->Node.ln_Pred;
  155.         Remove(( struct Node * )bf );
  156.         FreeMem( bf, sizeof( struct BFInfo ));
  157.         bf = bf2;
  158.     }
  159. }
  160. ///
  161. /// IEX_Edit
  162. __geta4 BOOL IEX_Edit( __D0 UWORD ID, __A0 struct IE_Data *IE )
  163. {
  164.     return( FALSE );
  165. }
  166. ///
  167. /// IEX_Copy
  168. __geta4 BOOL IEX_Copy( __D0 UWORD ID, __A0 struct IE_Data *IE, __D1 WORD offx, __D2 WORD offy )
  169. {
  170.     return( TRUE );
  171. }
  172. ///
  173. /// IEX_Make
  174. __geta4 struct Gadget *IEX_Make( __D0 UWORD ID, __A0 struct IE_Data *IE, __A1 struct Gadget *glist )
  175. {
  176.     /*  We don't need to make anything  */
  177.     return( glist );
  178. }
  179. ///
  180. /// IEX_Free
  181. __geta4 void IEX_Free( __D0 UWORD ID, __A0 struct IE_Data *IE )
  182. {
  183.     /*  We've got nothing to free when the window is closed  */
  184. }
  185. ///
  186. /// IEX_Refresh
  187. __geta4 void IEX_Refresh( __D0 UWORD ID, __A0 struct IE_Data *IE )
  188. {
  189.     struct BFInfo *bf;
  190.  
  191.     for( bf = IE->win_info->wi_Gadgets.mlh_Head; bf->Node.ln_Succ; bf = bf->Node.ln_Succ ) {
  192.     /*  always check the Kind  */
  193.     if( bf->Kind == ID ) {
  194.         struct DrawInfo *dri;
  195.         static UWORD Pattern[2] = { 0xAAAA, 0x5555 };
  196.  
  197.         if( dri = GetScreenDrawInfo( IE->ScreenData->Screen )) {
  198.  
  199.         SetAPen( IE->win_info->wi_winptr->RPort, dri->dri_Pens[ SHINEPEN ]);
  200.         SetAfPt( IE->win_info->wi_winptr->RPort, &Pattern[0], 1 );
  201.  
  202.         RectFill( IE->win_info->wi_winptr->RPort, IE->win_info->wi_winptr->BorderLeft, IE->win_info->wi_winptr->BorderTop,
  203.               IE->win_info->wi_winptr->Width - IE->win_info->wi_winptr->BorderRight - 1,
  204.               IE->win_info->wi_winptr->Height - IE->win_info->wi_winptr->BorderBottom - 1 );
  205.  
  206.         SetAfPt( IE->win_info->wi_winptr->RPort, NULL, 0 );
  207.  
  208.         FreeScreenDrawInfo( IE->ScreenData->Screen, dri );
  209.         }
  210.  
  211.         return; /* there's just one BackFill a window...  */
  212.     }
  213.     }
  214. }
  215. ///
  216.  
  217.  
  218. /*  I/O Functions               */
  219. /// IEX_Save
  220. __geta4 void IEX_Save( __D0 UWORD ID, __A0 struct IE_Data *IE, __D1 BPTR File )
  221. {
  222. }
  223. ///
  224. /// IEX_Load
  225. __geta4 BOOL IEX_Load( __D0 UWORD ID, __A0 struct IE_Data *IE, __D1 BPTR File, __D2 UWORD Num )
  226. {
  227.     struct BFInfo   *bf;
  228.  
  229.     if( bf = AllocMem( sizeof( struct BFInfo ), MEMF_CLEAR )) {
  230.  
  231.     bf->Kind = ID;  /* VERY important!!! */
  232.  
  233.     AddTail(( struct List * )&IE->win_info->wi_Gadgets, ( struct Node * )bf );
  234.  
  235.     } else
  236.     return( FALSE );
  237.  
  238.     return( TRUE );
  239. }
  240. ///
  241.  
  242.  
  243. /*  Source related functions    */
  244. /// IEX_StartSrcGen
  245. __geta4 STRPTR IEX_StartSrcGen( __D0 UWORD ID, __A0 struct IE_Data *IE )
  246. {
  247.     struct WindowInfo *wnd;
  248.     struct BFInfo     *bf;
  249.  
  250.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  251.     if( wnd->wi_NumObjects ) {
  252.         for( bf = wnd->wi_Gadgets.mlh_Head; bf->Node.ln_Succ; bf = bf->Node.ln_Succ ) {
  253.         if( bf->Kind == ID ) {
  254.             wnd->wi_NeedRender = TRUE;
  255.             break;
  256.         }
  257.         }
  258.     }
  259.     }
  260.  
  261.     return(( *IE->IEXFun->GetFirstLine )( Desc, "SUPPORT" ));
  262. }
  263. ///
  264. /// IEX_WriteGlobals
  265. __geta4 void IEX_WriteGlobals( __D0 UWORD ID, __A0 struct GenFiles *Files, __A1 struct IE_Data *IE )
  266. {
  267.     UBYTE   *String;
  268.  
  269.     if( String = ( *IE->IEXFun->GetFirstLine )( Desc, "GLOBAL" ))
  270.     FPuts( Files->Std, String );
  271. }
  272. ///
  273. /// IEX_WriteSetup
  274. __geta4 void IEX_WriteSetup( __D0 UWORD ID, __A0 struct GenFiles *Files, __A1 struct IE_Data *IE )
  275. {
  276. }
  277. ///
  278. /// IEX_WriteCloseDown
  279. __geta4 void IEX_WriteCloseDown( __D0 UWORD ID, __A0 struct GenFiles *Files, __A1 struct IE_Data *IE )
  280. {
  281. }
  282. ///
  283. /// IEX_WriteHeaders
  284. __geta4 void IEX_WriteHeaders( __D0 UWORD ID, __A0 struct GenFiles *Files, __A1 struct IE_Data *IE )
  285. {
  286.     STRPTR string;
  287.  
  288.     if( string = ( *IE->IEXFun->GetFirstLine )( Desc, "HEADER" ))
  289.     FPuts( Files->XDef, string );
  290.  
  291.     if( string = ( *IE->IEXFun->GetFirstLine )( Desc, "INCLUDE" ))
  292.     FPuts( Files->Std, string );
  293. }
  294. ///
  295. /// IEX_WriteRender
  296. __geta4 void IEX_WriteRender( __D0 UWORD ID, __A0 struct GenFiles *Files, __A1 struct IE_Data *IE )
  297. {
  298.     struct Descriptor   Dsc[] = {
  299.     { 'w', IE->win_info->wi_Label },
  300.     { 0, NULL }
  301.     };
  302.     struct BFInfo   *bf;
  303.     STRPTR           String;
  304.  
  305.     if(( IE->win_info->wi_NumObjects ) && ( String = ( *IE->IEXFun->GetFirstLine )( Desc, "RENDER" ))) {
  306.     for( bf = IE->win_info->wi_Gadgets.mlh_Head; bf->Node.ln_Succ; bf = bf->Node.ln_Succ ) {
  307.         if( bf->Kind == ID ) {
  308.         ( *IE->IEXFun->WriteFormatted )( Files->Std, String, &Dsc[0] );
  309.         }
  310.     }
  311.     }
  312. }
  313. ///
  314. /// IEX_GetIDCMP
  315. __geta4 ULONG IEX_GetIDCMP( __D0 UWORD ID, __D1 ULONG idcmp, __A0 struct IE_Data *IE )
  316. {
  317.     return( idcmp );
  318. }
  319. ///
  320. /// IEX_WriteData
  321. __geta4 void IEX_WriteData( __D0 UWORD ID, __A0 struct GenFiles *Files, __A1 struct IE_Data *IE )
  322. {
  323. }
  324. ///
  325. /// IEX_WriteChipData
  326. __geta4 void IEX_WriteChipData( __D0 UWORD ID, __A0 struct GenFiles *Files, __A1 struct IE_Data *IE )
  327. {
  328. }
  329. ///
  330. /// IEX_WriteOpenWnd
  331. __geta4 void IEX_WriteOpenWnd( __D0 UWORD ID, __A0 struct GenFiles *Files, __A1 struct IE_Data *IE )
  332. {
  333. }
  334. ///
  335. /// IEX_WriteCloseWnd
  336. __geta4 void IEX_WriteCloseWnd( __D0 UWORD ID, __A0 struct GenFiles *Files, __A1 struct IE_Data *IE )
  337. {
  338. }
  339. ///
  340.